package com.cxrj.zhsq.userManage.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cxrj.zhsq.userManage.service.DoorService;

@Controller
public class DoorController {

	@Resource
	private DoorService doorService;

	/**
	 * 分页查询门
	 * 
	 * @return
	 */
	@RequestMapping(value = "selectDoors", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	@ResponseBody
	public Map<String, Object> selectRoles(HttpServletRequest request, HttpServletResponse response) {
		return doorService.selectDoorsPager(request, response);
	}

	/**
	 * 同步门
	 * 
	 * @return
	 */
	@RequestMapping(value = "insertDoors", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> insertDoors(HttpServletRequest request) {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try {
			resultMap = doorService.insertDoors();
		} catch (Exception e) {
			resultMap.put("result", 0);
			e.printStackTrace();
		}
		return resultMap;
	}
}
